<template>
  <default-home-card icon="BarChartOutlined" title="企业推广设备">
    <div class="echarts-box">
      <div class="gradient-main" id="gradient-main"></div>
    </div>
  </default-home-card>
</template>
<script setup>
  import DefaultHomeCard from '/@/views/system/home/components/default-home-card.vue';
  import * as echarts from 'echarts';
  import { onMounted } from 'vue';

  onMounted(() => {
    init();
  });

  function init() {
    let option = {
      tooltip: {
        trigger: 'axis'
      },
      legend: {
        data: ['A公司', 'B公司', 'C公司', 'D公司', 'E公司']
      },
      grid: {
        left: '3%',
        right: '3%',
        bottom: '3%',
        containLabel: true
      },
      toolbox: {
        feature: {
          saveAsImage: {}
        }
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['2024-08-08', '2024-08-09', '2024-08-10', '2024-08-11', '2024-08-12', '2024-08-13', '2024-08-14']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          name: 'A公司',
          type: 'line',
          stack: 'Total',
          smooth: true,
          data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
          name: 'B公司',
          type: 'line',
          stack: 'Total',
          smooth: true,
          data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
          name: 'C公司',
          type: 'line',
          stack: 'Total',
          smooth: true,
          data: [150, 232, 201, 154, 190, 330, 210]
        },
        {
          name: 'D公司',
          type: 'line',
          stack: 'Total',
          smooth: true,
          data: [320, 332, 301, 334, 390, 330, 320]
        },
        {
          name: 'E公司',
          type: 'line',
          stack: 'Total',
          smooth: true,
          data: [220, 232, 101, 134, 290, 230, 120]
        }
      ]
    };
    let chartDom = document.getElementById('gradient-main');
    if (chartDom) {
      let myChart = echarts.init(chartDom);
      option && myChart.setOption(option);
    }
  }
</script>
<style lang="less" scoped>
  .echarts-box {
    display: flex;
    align-items: center;
    justify-content: center;
    .gradient-main {
      width: 90%;
      height: 450px;
      background: #fff;
    }
  }
</style>
